package com.coderman.infosys.auth.infrast.gatawayimpl;

import java.util.List;

import com.coderman.infosys.plat.auth.common.page.PageBO;
import com.coderman.infosys.auth.domain.bo.config.DataColumnBO;
import com.coderman.infosys.auth.domain.gataway.DataColumnConfigGataway;

import com.coderman.infosys.auth.infrast.dao.dataobject.DataColumnConfigDO;
import com.coderman.infosys.auth.infrast.dao.mapper.DataColumnConfigMapper;
import com.coderman.infosys.auth.infrast.dataconvert.DataColumnConvert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Description:数据字段配置接口实现类
 * @Author：
 * @CreateTime：2022-01-02 15:27:38
 * @version v1.0
 */
@Service
public class DataColumnConfigGatawayImpl  implements DataColumnConfigGataway{

    @Autowired
    private DataColumnConfigMapper dataColumnConfigMapper;

    @Override
	public Long saveDataColumn(DataColumnBO dataColumnBO){
        dataColumnConfigMapper.insert(DataColumnConvert.INSTANCE.bo2do(dataColumnBO));
        return dataColumnBO.getId();
    }

    @Override
	public Boolean saveBatchDataColumn(List<DataColumnBO> list){
        for (DataColumnBO dataColumnBO : list){
            dataColumnConfigMapper.insert(DataColumnConvert.INSTANCE.bo2do(dataColumnBO));
        }
        return true;
    }

    @Override
	public Long updateDataColumn(DataColumnBO dataColumnBO){
        dataColumnConfigMapper.update(DataColumnConvert.INSTANCE.bo2do(dataColumnBO));
        return dataColumnBO.getId();
    }

    @Override
	public DataColumnBO getById(Long id){
        return DataColumnConvert.INSTANCE.do2bo(dataColumnConfigMapper.getById(id));
    }

    @Override
	public List<DataColumnBO> getByBusDatabase(String busDataBase){
        return DataColumnConvert.INSTANCE.doList2boList(dataColumnConfigMapper.getByBusDatabase(busDataBase));
    }

    @Override
	public List<DataColumnBO> getPageList(PageBO pageBO){
        List<DataColumnConfigDO> dataColumnConfigDOS = dataColumnConfigMapper.getPageList(pageBO);
        int totalCount = dataColumnConfigMapper.getTotalCount(pageBO);
        pageBO.setTotalRows(totalCount);
        return DataColumnConvert.INSTANCE.doList2boList(dataColumnConfigDOS);
    }

}